-
-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Concept: functions #715
Concept: functions #715
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still in WIP/Draft state...
concepts/functions/introduction.md
Outdated
function funcname { COMMANDS; } | ||
``` | ||
|
||
There is no difference between the two styles. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we recommend the portable syntax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My personal preference, based on my time in the IRC channel, is for the portable version.
Mentioning two approaches without any suggestion in one direction or the other can leave someone new to the syntax a bit ... confused/adrift about which to use.
concepts/functions/introduction.md
Outdated
function funcname { COMMANDS; } | ||
``` | ||
|
||
There is no difference between the two styles. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My personal preference, based on my time in the IRC channel, is for the portable version.
Mentioning two approaches without any suggestion in one direction or the other can leave someone new to the syntax a bit ... confused/adrift about which to use.
concepts/functions/introduction.md
Outdated
``` | ||
~~~~ | ||
|
||
## Return Value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A function call has one return value. A function can have many calls and many return values.
A function variable has one name and one value (at any given time).
It feels very odd to me for them to be inconsistent.
## Recursion | ||
|
||
Functions can call themselves recursively. | ||
By default, there is no limit to the depth of recursion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No recursion limit ... but factorials would overflow pretty quickly 😄
95ba5c4
to
0626d48
Compare
Regarding the 2 ways to define a function, I simply removed one of them. Frustratingly even the google shell style guide mixes the styles. |
d831165
to
f72a5cf
Compare
Functions concept